package com.woniuxy.lab.woniu_lab.mqListener;

import com.woniuxy.lab.woniu_lab.model.Order;
import com.woniuxy.lab.woniu_lab.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@RocketMQMessageListener(topic = "add_order_topic",consumerGroup = "orderAdd")
@Slf4j
public class AddOrderListener implements RocketMQListener<Order> {

    @Resource
    private OrderService orderService;

    @Override
    public void onMessage(Order order) {
        log.info("新增订单到数据据库");
        orderService.save(order);
    }
}
